<?php
/*
 *
 *  form_zakazky.php
 *
 *
 */


if (isset($_POST["zobraz"]))
{
  if (isset($_POST["podzakazka"]))
  {
    Header("Location: http://".$_SERVER["SERVER_NAME"]."/index.php?type=base&det=detail");
  }
}

if (isset($_POST["edit"]))
{
  if (isset($_POST["podzakazka"]))
  {
    $url = urlencode($_POST["cz"]);
    Header("Location: http://".$_SERVER["SERVER_NAME"]."/index.php?type=base&det=pridat_zakazku&editz=".$url);
  }
}
/*
if (isset($_POST["tisk"]))
{
  if (isset($_POST["podzakazka"]))
  {
    $url = urlencode($_POST["podzakazka"]);
    Header("Location: http://".$_SERVER["SERVER_NAME"]."/tisk_zakazky.php?editpz=".$url);
  }
}
  */
if (isset($_POST["pridat_podzakazku"]))
{
  if (isset($_POST["podzakazka"]))
  {
    $url = urlencode($_POST["podzakazka"]);
    Header("Location: http://".$_SERVER["SERVER_NAME"]."/index.php?type=base&det=pridat_podzakazku&co=".$url);
  }
}


?>

<form name="form_z" id="form_zakazky" method="post" action="index.php?type=base&det=zakazky">
  <input type="text" name="rok" id="rok" value="<?php echo date(y)?>" size="2">

  <!-- cislo zakazky == cislo objednavky bez roku -->
  <input type="text" name="cislo_zakazky" id="cislo_zakazky" value="<?php echo $_POST["cislo_zakazky"]; ?>"
    onchange="document.forms.form_zakazky.submit()" />

  <!-- podzakazky, pokud je jich vice jak jedna -->
  <select name="podzakazka" id="podzakazka">
    <?php
    $select = "select cislo_objednavky from podzakazky where cislo_objednavky like '".$_POST["rok"]."-".$_POST["cislo_zakazky"]."%'";
    echo $select;
    $res = MySQL_Query("select cislo_objednavky from podzakazka where cislo_objednavky like '".$_POST["rok"]."-".$_POST["cislo_zakazky"]."%'", $spojeni);

    while ($pole = MySQL_Fetch_Array($res))
    {
      echo "<option value=\"".$pole["cislo_objednavky"]."\">".$pole["cislo_objednavky"]."</option>";
    }

    ?>

  </select>&nbsp;&nbsp;

  <!-- tlacitko zobraz zakazku -->
  <!--input type="submit" name="zobraz" id="zobraz" value="zobraz zakazku" //-->&nbsp;&nbsp;
  <input type="submit" name="edit" id="edit" value="edit"
    onclick="document.forms.form_z.target='_self';document.forms.form_z.action='index.php?type=base&det=pridat_podzakazku&editpz='+document.getElementById('podzakazka').value;document.forms.form_pz.submit()"/>&nbsp;&nbsp;
  <input type="submit" name="tisk" id="tisk" value="tisk"
    onclick="document.forms.form_z.target='_blank';document.forms.form_z.action='tisk_zakazky.php?editpz='+document.getElementById('podzakazka').value;document.forms.form_pz.submit()"/>

<!--
  <input type="submit" name="" id="" value="storno" />
  <input type="submit" name="pridat_podzakazku" id="pridat_podzakazku" value="pridat podzakazku" />&nbsp;&nbsp;


  hotovo pouze v menu touch
  <input type="submit" name="" id="" value="hotovo" /><br>

  <input type="submit" name="" id="" value="tisk stitku" />&nbsp;&nbsp;
  <input type="submit" name="" id="" value="zpet" />&nbsp;
-->
  <input type="hidden" name="cz" id="cz" value="<?php  echo "".$_POST["rok"]."-".$_POST["cislo_zakazky"]; ?>" />&nbsp;&nbsp;
</form>

<?php

$cz = "";
include "form_zakazka_b.php";


?>

